import { Body, Controller, Get, Post, Res, Session } from "@nestjs/common"
import { EmailService } from "./email.service"
import { Response } from "express"

@Controller("email")
export class EmailController {
  constructor(private readonly emailService: EmailService) {}

  // // Send email
  // @Post("/send")
  // async send(@Res() res: Response, @Body() body: object): Promise<void> {
  //   return await this.emailService.send(res, body)
  // }

  // Obtain email configuration
  @Get("/getConfig")
  async getConfig(@Res() res: Response): Promise<void> {
    return await this.emailService.getConfig(res)
  }

  // Save the email configuration
  @Post("/saveConfig")
  async saveConfig(@Res() res: Response, @Body() body: object): Promise<void> {
    return this.emailService.saveConfig(res, body)
  }

  // Generate email captcha
  @Post("/generateCaptcha")
  async generateCaptcha(
    @Body() body: object,
    @Session() session: object
  ): Promise<void> {
    return await this.emailService.generateCaptcha(body, session)
  }
}
